package com.cg.service.impl;

import com.cg.entity.Department;
import com.cg.dao.DepartmentMapper;
import com.cg.service.DepartmentService;

import com.cg.vo.DepartmentDoctorVo;
import com.cg.vo.DepartmentInfoVo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

/**
 * (Department)表服务实现类
 *
 * @author chengong
 * @since 2024-01-07 12:26:07
 */
@Service("departmentService")
public class DepartmentServiceImpl implements DepartmentService {
    @Resource
    private DepartmentMapper departmentMapper;


    /**
     * 根据院区id查询科室
     */
    @Override
    public List<Department> queryDepartmentByBranchId(Integer branchId) {
        return departmentMapper.queryDepartmentByBranchId(branchId);
    }

    /**
     * 根据科室名称模糊查询科室列表
     */
    @Override
    public List<Department> queryDepartmentByDepartmentName(String departmentName) {
        return departmentMapper.queryDepartmentByDepartmentName(departmentName);
    }


    /**
     * 根据科室id查询科室详情
     */
    @Override
    public DepartmentInfoVo queryDepartmentInfo(Integer departmentId) {
        //先查询科室详情
        DepartmentInfoVo departmentInfoVo = departmentMapper.queryDepartmentInfoByDepartmentId(departmentId);
        //查询科室下的医生
        List<DepartmentDoctorVo> departmentDoctorVoList = departmentMapper.queryDoctorListByDepartmentId(departmentId);
        departmentInfoVo.setDepartmentDoctorVoList(departmentDoctorVoList);
        return departmentInfoVo;
    }
}
